﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAL;
namespace BLL.Admin
{
    public class HocVanHelper
    {
        public static void Add_DanhMucHocVan(string Ten)
        {
            var db = Connect.GetDataContext<TimViecDataContext>("Strconnect");
            db.tbl_DM_HocVans.InsertOnSubmit(new tbl_DM_HocVan
            {
                Mota = Ten
            });
            db.SubmitChanges();
        }
        public static void Update_DMHocVan(int HocVanId, string Ten)
        {
            var db = Connect.GetDataContext<TimViecDataContext>("Strconnect");
            var dm = db.tbl_DM_HocVans.FirstOrDefault(k => k.HocVanId == HocVanId);
            if (dm != null)
            {
                dm.Mota = Ten;
                db.SubmitChanges();
            }
        }
        public static tbl_DM_HocVan Get_DMHocVan(int HocVanId)
        {
            var db = Connect.GetDataContext<TimViecDataContext>("Strconnect");
            return db.tbl_DM_HocVans.FirstOrDefault(k => k.HocVanId == HocVanId);
        }
        public static IQueryable List_DMHoVan()
        {
            var db = Connect.GetDataContext<TimViecDataContext>("Strconnect");
            var query = from dmcb in db.tbl_DM_HocVans
                        orderby dmcb.Mota ascending
                        select new
                        {
                            dmcb.HocVanId,
                            dmcb.Mota,
                        };
            return query;
        }
    }
}